//
//  EditViewModel.m
//  CoreData
//
//  Created by ZRAR on 16/1/18.
//  Copyright © 2016年 ZRAR. All rights reserved.
//

#import "EditViewModel.h"
#import "Person.h"
@implementation EditViewModel
- (instancetype)initWithModel:(id)model{
    
    self = [super initWithModel:model];
    if (self) {
        
        
        RACChannelTo(self,name) = RACChannelTo(self.model, name);
        RACChannelTo(self,phone) = RACChannelTo(self.model, phone);
        RACChannelTo(self,adress) = RACChannelTo(self.model, adress);
        RACChannelTo(self,email) = RACChannelTo(self.model, email);
        RACChannelTo(self,header) = RACChannelTo(self.model, header);
    }
    
    return self;
}

- (void)cancel{
    
    if (self.inserting) {
        
        [self.model.managedObjectContext deleteObject:self.model];
        
    }
    
}

- (void)willDismiss{
    
    [self.model.managedObjectContext save:nil];
    
}



@end
